import {
  GET_SWIPER_FN,
  GET_ICON_FN,
  GET_LIST_FN,
  GET_RECOMLIST_FN,
  GET_TARGET_FN,
  GET_SEARCH_FN
} from "./mutations-type";
import axios from "axios";
const actions = {
  //请求swiper
  async getSwiper({ commit }) {
    let res = await axios.get("/api/getSwiper");
    commit(GET_SWIPER_FN, res.data.results);
  },
  //请求的icons
  async getIconsList({ commit }) {
    let res = await axios.get("/api/getIconsList");
    commit(GET_ICON_FN, res.data.results);
  },
  //请求的home页商品列表
  async getListFn({ commit }) {
    let res = await axios.get("/api/getList");
    commit(GET_LIST_FN, res.data.results);
  },
  //请求推荐商品的列表
  async getRecomListFn({ commit }) {
    let res = await axios.get("/api/getRecomList");
    commit(GET_RECOMLIST_FN, res.data.results);
  },
  //跳转详情
  async getDetail({ commit }, id) {
    commit(GET_TARGET_FN, id);
  },
  //搜索页面的
  async getSearch({commit}){
    let res = await axios.get("/api/getSearchList");

    commit(GET_SEARCH_FN, res.data.ress.data);
  }
};
export default actions;
